﻿namespace ordinary_least_squares
{
    internal class Program
    {
        static void Main(string[] args)
        {
            Point[] points = new Point[21];
            //还能通过points[].X=   ;points[].Y=.来赋值
            //调用构造函数
            points[0] = new Point(2000, 1211346869600);
            points[1] = new Point(2001, 1339395718862);
            points[2] = new Point(2002, 1470550015077);
            points[3] = new Point(2003, 1660287965663);
            points[4] = new Point(2004, 1955347004965);
            points[5] = new Point(2005, 2285965892364);
            points[6] = new Point(2006, 2752131773358);
            points[7] = new Point(2007, 3550342737009);
            points[8] = new Point(2008, 4594307032667);
            points[9] = new Point(2009, 5101703073088);
            points[10] = new Point(2010, 6087163874510);
            points[11] = new Point(2011, 7551500124197);
            points[12] = new Point(2012, 8532229986993);
            points[13] = new Point(2013, 9570406235659);
            points[14] = new Point(2014, 10475682920597);
            points[15] = new Point(2015, 11061553079871);
            points[16] = new Point(2016, 11233276536744);
            points[17] = new Point(2017, 12310409370894);
            points[18] = new Point(2018, 13894817549380);
            points[19] = new Point(2019, 14279937500608);
            points[20] = new Point(2020, 14687673892882);
            Console.WriteLine("输入年份");
            int year = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine($"{year}年预测值是{FunctionOfRegression.function(points,year)}");
            //拟合度测试，使用2021年的值
            double degreeOfFitting = (FunctionOfRegression.function(points, 2021) / 17734062645371) - 1;
            Console.WriteLine(degreeOfFitting);
            if (degreeOfFitting > -0.1 && degreeOfFitting < 0.1)
                Console.WriteLine("函数拟合度高");

        }
    }
}